def calculate(expression):
    left=expression.find('/')
    right=expression.rfind('/')
    string=expression[left+1:right]
    up1=int(expression[:left])
    down2=int(expression[right+1:])
    for character in string:
        if not character.isdigit():
            operation=character
            break
    rest=string.split(operation)
    down1=int(rest[0])
    up2=int(rest[1])
    if operation == '*':
        up=up1*up2
        down=down1*down2
    elif operation == '/':
        up=up1*down2
        down=down1*up2
    else:
        down=down1*down2
        up=eval(f'{up1*down2}{operation}{up2*down1}')
    return f'{up}/{down}'

def simplify(fraction):
    pair=fraction.split('/')
    up=int(pair[0])
    down=int(pair[1])
    base=min(up,down)
    for i in range(base,1,-1):
        if up%i == 0 and down%i == 0:
            up/=i
            down/=i
            base=min(up,down)
    if down == 1:
        return f'{int(up)}'
    return f'{int(up)}/{int(down)}'

print(simplify(calculate('1/2+1/4')))
print(simplify(calculate('1/4/1/2')))
